home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / C++ AppleLink Messages / CPlus.Dev$ 3⁄30⁄90 / 0093-Re Fast allocation-Mar90 < prev    next >
Encoding:
Text File  |  1990-03-30  |  1.3 KB  |  33 lines  |  [TEXT/GEOL]

  1. Item forwarded  by  LEFFLER1     to RON.METZKER
  2.  
  3. Item    3720290                         28-March-90        10:15PST
  4.  
  5. From:   PALEVICH1                       Palevich, John
  6.  
  7. To:     CPLUS.DEV$                      C++ Interest List--Developers
  8.         CPLUS.APPLE$                    C++ Interest List--Apple Employees
  9.  
  10. Sub:    RE Fast allocation
  11.  
  12. Don Park gives times for various memory allocation mechanisms:
  13.  
  14. 1.  NewPtr/DisposPtr = 461 ticks
  15. 2.  HandleObject     = 128 ticks
  16. 3.  new/delete      = 109 ticks
  17. 4.  malloc/free     =  85 ticks
  18. 5.  Arena         =  15 ticks
  19.  
  20. Don was puzzled why HandleObject was so much faster than NewPtr/DisposPtr.  I
  21. think the reason is that HandleObject allocates a relocatable block, (using
  22. NewHandle).  Relocatable blocks are usually faster to allocate than
  23. non-relocatable blocks.  This is because the Memory Manager takes extra pains
  24. to allocate a non-relocatable block at the bottom of the heap.  The Memory
  25. Manager will even move relocatable blocks upward to make room for a new
  26. non-relocatable block.  This is done to minimize heap fragmentation.  A side
  27. effect of this extra movement is that NewPtr calls are usually slower than
  28. NewHandle calls.
  29.  
  30. See "The Secret Life of the Memory Manager", by Richard Clark, in the
  31. soon-to-be-published second issue of Develop magazine for more details.
  32.  
  33.